<script type="text/javascript">
	function doSearchMatchDynamic(value) {
		
	}
	
	//表格查询  
	function reloadMatchDynamic() {
		var params = matchDynamic_list${(matchProjectItem.id)!}.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		matchDynamic_list${(matchProjectItem.id)!}.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		matchDynamic_list${(matchProjectItem.id)!}.datagrid('unselectAll');
		matchDynamic_list${(matchProjectItem.id)!}.datagrid('uncheckAll');
	}


	function addMatchDynamic() {
// 		createFromWindow("新增信息", "matchDynamic.do?editMatchDynamic&matchProjectId=${(matchProjectItem.id)!}", "matchDynamic.do?saveMatchDynamic",
// 				function(data) {
// 					reloadMatchDynamic();
// 				});
		createFromWindowOptions({
			title:"新增信息",
			maximizable:true,
			width:1100,
			height:500,
			href:"matchDynamic.do?editMatchDynamic&matchProjectId=${(matchProjectItem.id)!}",
			callback:function(d) {
				var rowData2 = d.form("getData");
				var ckData = CKEDITOR.instances.matchDynamicItemContent.getData();
				var formData = d.form("getData");
				formData.dynContent = ckData;
				
				$.ajax({
	           	  type: 'POST',
	           	  url: "matchDynamic.do?saveMatchDynamic",
	              dataType : 'json',  
	           	  data: formData,
	           	  success: function(data) {
	           		  showMsg(data.msg);
	           		  if(data.success) {
	           			reloadMatchDynamic();
		           	  }
	           	  },
		          error:function(data,textstatus){  
		        	  printLog(data);
		        	  showMsg('请求异常');
		           }  
	           	});
				
			},
			enableSaveButton:true
		});
	}
	
	function deleteMatchDynamic() {
		var rows = matchDynamic_list${(matchProjectItem.id)!}.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchDynamic.do?deleteMatchDynamicItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchDynamic();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	function publishMatchDynamic() {
		var rows = matchDynamic_list${(matchProjectItem.id)!}.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要发布吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchDynamic.do?publishMatchDynamicItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchDynamic();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	function revokeMatchDynamic() {
		var rows = matchDynamic_list${(matchProjectItem.id)!}.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要撤销吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('matchDynamic.do?revokeMatchDynamicItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadMatchDynamic();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	

	function editMatchDynamic() {
		var rows = matchDynamic_list${(matchProjectItem.id)!}.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
// 			createFromWindow("编辑信息", "matchDynamic.do?editMatchDynamic&matchDynamicId=" + rows[0].id,
// 					"matchDynamic.do?saveMatchDynamic", function(data) {
// 						reloadMatchDynamic();
// 					},true);
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				width:1100,
				height:500,
				href:"matchDynamic.do?editMatchDynamic&matchProjectId=${(matchProjectItem.id)!}&matchDynamicId=" + rows[0].id,
				callback:function(d) {
					var rowData2 = d.form("getData");
					var ckData = CKEDITOR.instances.matchDynamicItemContent.getData();
					var formData = d.form("getData");
					formData.dynContent = ckData;
					
					$.ajax({
		           	  type: 'POST',
		           	  url: "matchDynamic.do?saveMatchDynamic",
		              dataType : 'json',  
		           	  data: formData,
		           	  success: function(data) {
		           		  showMsg(data.msg);
		           		  if(data.success) {
		           			reloadMatchDynamic();
			           	  }
		           	  },
			          error:function(data,textstatus){  
			        	  printLog(data);
			        	  showMsg('请求异常');
			           }  
		           	});
					
				},
				enableSaveButton:'1'!=rows[0].publishStatu //非发布的
			});
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	function lookMatchDynamic() {
		var rows = matchDynamic_list${(matchProjectItem.id)!}.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			window.open('match.action?getMatchDynaContent&id='+rows[0].id);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	
	function clearMatchDynamicSearch${(matchProjectItem.id)!}() {
		setGridSearchParams('matchDynamic_list${(matchProjectItem.id)!}','matchDynamicSearchForm',true,reloadMatchDynamic);
	}
	
	//根据条件查询
	function matchDynamicSearch${(matchProjectItem.id)!}() {
		setGridSearchParams('matchDynamic_list${(matchProjectItem.id)!}','matchDynamicSearchForm',false,reloadMatchDynamic);
	}
	
	function onDblClickMatchDynamicRow(rowIndex, rowData) {
// 		createFromWindow("编辑信息", "matchDynamic.do?editMatchDynamic&matchDynamicId=" + rowData.id,
// 					"matchDynamic.do?saveMatchDynamic", function(data) {
// 						reloadMatchDynamic();
// 					},true);
		createFromWindowOptions({
			title:"编辑信息",
			maximizable:true,
			width:1100,
			height:500,
			href:"matchDynamic.do?editMatchDynamic&matchProjectId=${(matchProjectItem.id)!}&matchDynamicId=" + rowData.id,
			callback:function(d) {
				var rowData2 = d.form("getData");
				var ckData = CKEDITOR.instances.matchDynamicItemContent.getData();
				var formData = d.form("getData");
				formData.dynContent = ckData;
				
				$.ajax({
	           	  type: 'POST',
	           	  url: "matchDynamic.do?saveMatchDynamic",
	              dataType : 'json',  
	           	  data: formData,
	           	  success: function(data) {
	           		  showMsg(data.msg);
	           		  if(data.success) {
	           			reloadMatchDynamic();
		           	  }
	           	  },
		          error:function(data,textstatus){  
		        	  printLog(data);
		        	  showMsg('请求异常');
		           }  
	           	});
				
			},
			enableSaveButton:'1'!=rowData.publishStatu //非发布的
		});
	}
	
	
</script>


<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="matchDynamic_list${(matchProjectItem.id)!}" toolbar="#matchDynamiclist_search${(matchProjectItem.id)!}" idField="id"  url="matchDynamic.do?loadList&matchProjectId=${(matchProjectItem.id)!}" rownumbers="true" onDblClickRow="onDblClickMatchDynamicRow(rowIndex, rowData)"
			 item="com.xdtech.match.vo.MatchDynamicItem"/>
		
		<div id="matchDynamiclist_search${(matchProjectItem.id)!}">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="matchDynamicSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td colspan="2">
<!-- 							<input id="matchDynamicProjectId${(matchProjectItem.id)!}" name="matchProjectId" type="hidden" value="${(matchProjectItem.id)!}" /> -->
							当前赛事：${(matchProjectItem.matName)!}
							</td>
						</tr>
					</table>
					<table>
						<tr>
							<td>文章名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" style="width: 150px"/></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="matchDynamicSearch${(matchProjectItem.id)!}()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearMatchDynamicSearch${(matchProjectItem.id)!}()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="matchDynamic_toolbar${(matchProjectItem.id)!}" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="match:matchDynamic:add" iconCls="icon-add" onclick="addMatchDynamic()"/>
				<@eu.linkbutton showName="删除" shiro="match:matchDynamic:delete" iconCls="icon-remove" onclick="deleteMatchDynamic()"/>
				<@eu.linkbutton showName="编辑" shiro="match:matchDynamic:edit" iconCls="icon-edit" onclick="editMatchDynamic()"/>
				<@eu.linkbutton showName="发布" shiro="match:matchDynamic:publish" iconCls="icon-edit" onclick="publishMatchDynamic()"/>
				<@eu.linkbutton showName="预览" shiro="match:matchDynamic:look" iconCls="icon-edit" onclick="lookMatchDynamic()"/>
				<@eu.linkbutton showName="撤销" shiro="match:matchDynamic:revoke" iconCls="icon-edit" onclick="revokeMatchDynamic()"/>
				<@eu.linkbutton showName="刷新" shiro="match:matchDynamic:refresh" iconCls="icon-reload" onclick="reloadMatchDynamic()"/>
			</div>
		</div>
	</div>
</div>